/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/16
\**********************/
#include "LuaOption.h"

#define CObjPtr ((COptionUI*)m_cobj)

namespace DuiLib {

bool LuaOption::Activate()
{
    return CObjPtr->Activate();
}

void LuaOption::SetEnabled(bool bEnable)
{
    CObjPtr->SetEnabled(bEnable);
}

int LuaOption::GetSelectedImage(LuaState *L)
{
    SDTString str = CObjPtr->GetSelectedImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaOption::SetSelectedImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetSelectedImage(str.c_str());
    return 0;
}

int LuaOption::GetSelectedHotImage(LuaState *L)
{
    SDTString str = CObjPtr->GetSelectedHotImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaOption::SetSelectedHotImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetSelectedHotImage(str.c_str());
    return 0;
}

int LuaOption::GetSelectedPushedImage(LuaState *L)
{
    SDTString str = CObjPtr->GetSelectedPushedImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaOption::SetSelectedPushedImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetSelectedPushedImage(str.c_str());
    return 0;
}

int LuaOption::GetSelectedForedImage(LuaState *L)
{
    SDTString str = CObjPtr->GetSelectedForedImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaOption::SetSelectedForedImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetSelectedForedImage(str.c_str());
    return 0;
}

void LuaOption::SetSelectedTextColor(DWORD dwColor)
{
    CObjPtr->SetSelectedTextColor(dwColor);
}

DWORD LuaOption::GetSelectedTextColor()
{
    return CObjPtr->GetSelectedTextColor();
}

void LuaOption::SetSelectedBkColor(DWORD dwColor)
{
    CObjPtr->SetSelectedBkColor(dwColor);
}

DWORD LuaOption::GetSelectBkColor()
{
    return CObjPtr->GetSelectBkColor();
}

int LuaOption::GetGroup(LuaState *L)
{
    SDTString str = CObjPtr->GetGroup();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaOption::SetGroup(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    if (!str.empty()) {
        CObjPtr->SetGroup(str.c_str());
    } else {
        CObjPtr->SetGroup(NULL);
    }
    return 0;
}

bool LuaOption::IsSelected()
{
    return CObjPtr->IsSelected();
}

void LuaOption::Selected(bool bSelected)
{
    CObjPtr->Selected(bSelected);
}

SDLUA_BEGIN_REGISTER(LuaOption, Option, Button)
    SDLUA_REGISTER_FUN_CPP(LuaOption, Activate, Activate)
    SDLUA_REGISTER_FUN_CPP(LuaOption, SetEnabled, SetEnabled)

    SDLUA_REGISTER_FUN_LUA(LuaOption, GetSelectedImage, GetSelectedImage)
    SDLUA_REGISTER_FUN_LUA(LuaOption, SetSelectedImage, SetSelectedImage)
    SDLUA_REGISTER_FUN_LUA(LuaOption, GetSelectedHotImage, GetSelectedHotImage)
    SDLUA_REGISTER_FUN_LUA(LuaOption, SetSelectedHotImage, SetSelectedHotImage)
    SDLUA_REGISTER_FUN_LUA(LuaOption, GetSelectedPushedImage, GetSelectedPushedImage)
    SDLUA_REGISTER_FUN_LUA(LuaOption, SetSelectedPushedImage, SetSelectedPushedImage)

    SDLUA_REGISTER_FUN_LUA(LuaOption, GetSelectedForedImage, GetSelectedForedImage)
    SDLUA_REGISTER_FUN_LUA(LuaOption, SetSelectedForedImage, SetSelectedForedImage)
    
    SDLUA_REGISTER_FUN_CPP(LuaOption, SetSelectedTextColor, SetSelectedTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaOption, GetSelectedTextColor, GetSelectedTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaOption, SetSelectedBkColor, SetSelectedBkColor)
    SDLUA_REGISTER_FUN_CPP(LuaOption, GetSelectBkColor, GetSelectBkColor)

    SDLUA_REGISTER_FUN_LUA(LuaOption, GetGroup, GetGroup)
    SDLUA_REGISTER_FUN_LUA(LuaOption, SetGroup, SetGroup)

    SDLUA_REGISTER_FUN_CPP(LuaOption, IsSelected, IsSelected)
    SDLUA_REGISTER_FUN_CPP(LuaOption, Selected, Selected)
    
SDLUA_END_REGISTER

SDLUA_BEGIN_UNREGISTER(LuaOption, Option)
SDLUA_END_UNREGISTER(Option)

}

#undef CObjPtr